package com.candy.control;


import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;


public class HelloController implements Controller{


    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
//        创建视图模型对象
        ModelAndView modelAndView=new ModelAndView();
//        设置视图名字
        modelAndView.setViewName("HelloWorld");
//        可以传递参数到视图中
        modelAndView.addObject("msg","这是SpringMVC的第一个程序.."+new Date());
//        最后将视图返回，由视图解析器进行解析
//        /WEB-INF/pages/HelloWorld..jsp
        return modelAndView;
    }
}
